﻿ <div class="tableform">
    <div class="ratetab">
    <ul>
        <li class="selected" onclick="SelectTab(this,1)"><a>基本设置</a></li>
        <li onclick="SelectTab(this,2)"><a>标题图片</a></li>
        <li onclick="SelectTab(this,3)"><a>广告图片</a></li>
    </ul>
    </div>
    <div class="clear"></div>
    <div class="ratebox">
   
    <table id="tab1">
      <tr>
             <td align="left">栏目标题：<input type="text" name="txtarticletitle" id="txtarticletitle" class="input-text" /></td>
        <td align="left" style="margin-left:20px;">显示数量：<input type="text" name="txtarticlemaxnum" id="txtarticlemaxnum" class="input-text" /></td>
        </tr>
        <tr>
            <td colspan="2" align="left" valign="top">
               <p style="float:left"> 文章分类：</p><select id="slscategory" size="5" class="selectmult"></select>
            </td>
        </tr>
         <tr>
             
        </tr>
    </table>

    <table id="tab2" style="display:none">
                 <tr>
                    <td>
                         <div id="title_picture" class="show_img">
                   <ul><li><a><img  width="80px" height="80px" src="http://images.net.92hidc.net/storage/none.gif" /><i></i></a></li></ul>
                 </div>
                     </td>
                 </tr>
                 <tr><td><iframe src="" id="Seltitframe" name="Seltitframe" width="655px" scrolling="no" frameborder="0" style="display: inline; height: 300px;"></iframe></td></tr>
                 </table>

    <table id="tab3" style="display:none">
        <tr><td>
        <div id="banner_picture" class="show_img">
        <ul><li><a><img src="http://images.net.92hidc.net/storage/none.gif"  width="80px" height="80px"/><i></i></a></li></ul>
        </div></td></tr>
        <tr><td><iframe src="" id="Seliframe" name="Seliframe" width="655px" scrolling="no" frameborder="0" style="display: inline; height: 300px;"></iframe></td></tr>
    </table>
    </div>
</div>

<script type="text/javascript">
    function SelectTab(obj, suoyin) {
        $(obj).addClass("selected").siblings().removeClass("selected");
        $("#tab" + suoyin).css("display", "block").siblings().css("display", "none");
    }

    //删除图片
    function RemovetempImg(currentobj) {
        if ($(currentobj).prev("img").attr("src") != "http://images.net.92hidc.net/storage/none.gif")
            $(currentobj).prev("img").attr("src", "http://images.net.92hidc.net/storage/none.gif");
    }

    function loadEditDialogData() {
        Hidistro_Dialog.dialogContent = $(taboverlaycontent).html();
        Hidistro_Dialog.dialogShow();
        Hidistro_Dialog.dialogTitle($(ctrnamediv).html());

        $(".show_img i").bind("click", function () {
            RemovetempImg(this);
        });

        $.ajax({
            url: "Handler/DesigComments.ashx",
            async: false,
            type: "post",
            data: {
                ModelId: "commentarticleview"
            },
            dataType: "json",
            success: function (msg) {
                if (msg.success) {
                    DataBindValue(msg.Result);
                } else {
                    art.dialog({ content: msg.Result, lock: true, icon: "error" });
                }
            },
            complete: function () {
                BindCommentArticleEvent();
            }
        });
    }

    function SaveElmentValue() {

        if ($("#txtarticlemaxnum").val().replace(/\s/g, "") == "") {
            Hidistro_Dialog.dialogTip('error', '文章数量不允许为空');
            return false;
        }
        if (isNaN($("#txtarticlemaxnum").val().replace(/\s/g, ""))
        || parseInt($("#txtarticlemaxnum").val().replace(/\s/g, "")) <= 0
        || parseInt($("#txtarticlemaxnum").val().replace(/\s/g, "")) >100) {
            Hidistro_Dialog.dialogTip('error', '文章数量必须为1~100的正整数');
            return false;
        }

        var titleimg = "";
        var bannerimg = "";
        if ($("#title_picture img:eq(0)").attr("src") != "http://images.net.92hidc.net/storage/none.gif") {
            titleimg = $("#title_picture img:eq(0)").attr("src");
        }
        if ($("#banner_picture img:eq(0)").attr("src") != "http://images.net.92hidc.net/storage/none.gif") {
            bannerimg = $("#banner_picture img:eq(0)").attr("src");
        }
        var categoryId = "";
        if ($("#slscategory").val() != null) {
            categoryId = $("#slscategory").val();
        }

        $.ajax({
            url: "Handler/DesigComments.ashx",
            async: false,
            type: "post",
            data: {
                ModelId: "editecommentarticle",
                Param: "{\"Id\":\"" + Hidistro_designer.CurrentContentID +
                            "\",\"Title\":\"" + $("#txtarticletitle").val() +
                            "\",\"ImageTitle\":\"" + titleimg +
                            "\",\"AdImage\":\"" + bannerimg +
                            "\",\"CategoryId\":\"" + categoryId +
                            "\",\"MaxNum\": \"" + $("#txtarticlemaxnum").val() + "\"}"
            },
            dataType: "json",
            success: function (msg) {
                if (msg.success) {
                    $("#" + Hidistro_designer.CurrentContentID).replaceWith(msg.Result.ComArticle);
                    Hidistro_Dialog.dialogTip("succeed", "文章标签更新成功");
                } else {
                    Hidistro_Dialog.dialogTip("error", msg.Result);
                }
            },
            complete: function () {
                Hidistro_designer.BindSingleEvent(Hidistro_designer.CurrentContentID, true);
            }
        });
    }

    function DataBindValue(commentArticleJson) {

        if (commentArticleJson.length > 0) {
            $("#slscategory").empty();
            $("#slscategory").append("<option value='' selected='selected'>所有分类</option>");
            $.each(commentArticleJson, function (index, item) {
                $("#slscategory").append("<option value=\"" + item.CategoryId+ "\">" + item.Name + "</option>");
            });
        }
    }

    function BindCommentArticleEvent(){
        if (Hidistro_designer.ElementValues != null) {
            if(Hidistro_designer.ElementValues.Title!=""&&Hidistro_designer.ElementValues.Title!=null){
                $("#txtarticletitle").val(Hidistro_designer.ElementValues.Title);
            }

            if (Hidistro_designer.ElementValues.ImageTitle != "") {
                $("#title_picture img:eq(0)").attr("src", Hidistro_designer.ElementValues.ImageTitle);
            }
            if (Hidistro_designer.ElementValues.AdImage != "") {
                $("#banner_picture img:eq(0)").attr("src", Hidistro_designer.ElementValues.AdImage);
            }
            if(Hidistro_designer.ElementValues.CategoryId!=""&&Hidistro_designer.ElementValues.CategoryId!=null){
                $("#slscategory option[value='"+Hidistro_designer.ElementValues.CategoryId+"']").attr("selected",true);
            }
            if(Hidistro_designer.ElementValues.MaxNum!=""&&Hidistro_designer.ElementValues.MaxNum!=null){
                $("#txtarticlemaxnum").val(Hidistro_designer.ElementValues.MaxNum);
            }

            if (Hidistro_designer.ElementValues.AdImageSize != null && Hidistro_designer.ElementValues.AdImageSize != "") {
                $("#Seliframe").attr("src", "DialogTemplates/SelectImage.aspx?size=" + Hidistro_designer.ElementValues.AdImageSize + "&type=advertimg");
            }

            if (Hidistro_designer.ElementValues.TitleImageSize != null && Hidistro_designer.ElementValues.TitleImageSize != "") {
                $("#Seltitframe").attr("src", "DialogTemplates/SelectImage.aspx?size=" + Hidistro_designer.ElementValues.TitleImageSize + "&type=titleimg");
            }
        }
    }

</script>